// component/tabbar/index.js
const app = getApp()
Component({
  lifetimes:{

  },
  pageLifetimes:{
    show(){
      console.log('组件加载')
    }
  },
  /**
   * 组件的属性列表
   */
  properties: {
    tabbarindex:{
      value:'',
      type:Number
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    imgurl:app.imgurl,
    tabbar:[
      { img: 'img01.png', img_active:'img00.png',text:'首页',type:'1',url:'/pages/index/index'},
      { img: 'img02.png', img_active: 'img03.png', text: '排行榜', type: '1', url: '/pages/rankinglist/list' },
      { img: 'img04.png', img_active: '', text: '能量通道', type: '2', url: '/pages/energy/energy' },
      { img: 'img05.png', img_active: 'img010.png', text: '我的', type: '1', url: '/pages/my/index' },
    ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    navTo:function(e){
      var type = e.currentTarget.dataset.type;
      console.log(this.data.tabbarindex)
      console.log(e.currentTarget.dataset.index,'---e')
      if (this.data.tabbarindex != e.currentTarget.dataset.index){
        if (type == 1) {
          app.navlaunch(e.currentTarget.dataset.url)
        } else {
          app.navTo(e.currentTarget.dataset.url)
        }
      }
    }
  }
})
